package com.ougy.reshop.interceptor;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.ougy.reshop.model.User;

public class ManagerAuthInterceptor extends AbstractInterceptor {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1061490141086906962L;
	private Logger logger = Logger.getLogger(getClass());
	private String name;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String intercept(ActionInvocation arg0) throws Exception {
		User user = (User) ActionContext.getContext().getSession().get("user");
		if ((user != null) && (user.getId() != 0)) {
			logger.debug("UserAuth拦截器:已登录");
			return arg0.invoke();
		}
		logger.debug("UserAuth拦截器:未登录");
		return "noAuth";
	}

}
